package com.XinYun.Library.modules.borrow;

import com.XinYun.Library.modules.borrow.Service.Service;
import com.XinYun.Library.modules.borrow.Service.ServiceImpl;
import com.XinYun.Library.utils.HTTPRequestUtils.*;
import com.alibaba.fastjson.JSONObject;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

@WebServlet(name = "DischargingServlet", value = "/DischargingServlet")
public class DischargingServlet extends HttpServlet {
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String json = HTTPRequestUtil.getBody(request);
        //将JSON字符转化为JAVA对象
        System.out.println(request.getContextPath());
        JSONObject jsonObject = JSONObject.parseObject(json);
        String value = jsonObject.getString("bid");
        Service service = new ServiceImpl();
        Map<Object,Object> data1 = new HashMap<>();
        service.State1(value);
        data1.put("code",1);
        data1.put("message","还书成功");
        response.getWriter().write(data1.toString());
    }
}